home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.3
- date 88.03.27.21.17.12; author deboor; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 87.06.20.19.56.44; author deboor; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 87.06.16.12.21.00; author deboor; state Exp;
- branches ;
- next ;
-
-
- desc
- @Main I/O controller functions
- @
-
-
- 1.3
- log
- @*** empty log message ***
- @
- text
- @/*-
- * spriteIo.c --
- * Functions to handle input from the keyboard and mouse.
- *
- * Copyright (c) 1987 by the Regents of the University of California
- *
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- *
- *
- */
- #ifndef lint
- static char rcsid[] =
- "$Header: spriteIo.c,v 1.2 87/06/20 19:56:44 deboor Exp $ SPRITE (Berkeley)";
- #endif lint
-
- #include "spriteddx.h"
-
-
- Bool screenSaved = FALSE;
- /*
- * lastEventTime is used by the OS layer to decide when to do the screen
- * saver stuff. lastEventTimeMS is used by the cursor module when it generates
- * motion events in spriteSetCursorPosition. This is necessary because on
- * sun2's, the time in the keyboard events is relative to boot time, while
- * on sun3's it's real time, so what can you do?
- */
- unsigned int lastEventTime = 0;
- unsigned int lastEventTimeMS = 0;
-
- int spriteCheckInput = 0;
- #define RESTORE_CURSOR 0x01
- #define READ_INPUT 0x02
-
- /*-
- *-----------------------------------------------------------------------
- * spriteCursorGone --
- * This is a function required by the cursor code which is
- * just like spriteInputAvail, except it marks that the cursor
- * needs to be restored.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * spriteCheckInput is altered to contain the RESTORE_CURSOR flag.
- *
- *-----------------------------------------------------------------------
- */
- void
- spriteCursorGone()
- {
- spriteCheckInput |= RESTORE_CURSOR;
- }
-
- /*-
- *-----------------------------------------------------------------------
- * spriteInputAvail --
- * This function is called from the scheduler whenever one of
- * the devices we told it to look for has input waiting.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * spriteCheckInput has its READ_INPUT flag set.
- *
- *-----------------------------------------------------------------------
- */
- void
- spriteInputAvail()
- {
- spriteCheckInput |= READ_INPUT;
- }
-
- /*-
- *-----------------------------------------------------------------------
- * SetTimeSinceLastInputEvent --
- * Set the lastEventTime to now.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * lastEventTime is altered.
- *
- *-----------------------------------------------------------------------
- */
- void
- SetTimeSinceLastInputEvent()
- {
- SpriteTime now;
-
- Sys_GetTimeOfDay (&now, (int *)0, (Boolean *)0);
- lastEventTime = TVTOMILLI(now);
- }
-
- /*-
- *-----------------------------------------------------------------------
- * TimeSinceLastInputEvent --
- * Function used for screensaver purposes by the os module.
- *
- * Results:
- * The time in milliseconds since there last was any
- * input.
- *
- * Side Effects:
- * None.
- *
- *-----------------------------------------------------------------------
- */
- int
- TimeSinceLastInputEvent()
- {
- SpriteTime now;
-
- Sys_GetTimeOfDay(&now, (int *)NULL, (Boolean *)NULL);
-
- if (lastEventTime == 0) {
- lastEventTime = TVTOMILLI(now);
- }
- return TVTOMILLI(now) - lastEventTime;
- }
-
- /*-
- *-----------------------------------------------------------------------
- * ProcessInputEvents --
- * Retrieve all waiting input events and pass them to DIX in their
- * correct chronological order. The keyboard driver is responsible
- * for reading all the events (both for the mouse and the keyboard).
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Events are passed to the DIX layer.
- *
- *-----------------------------------------------------------------------
- */
- void
- ProcessInputEvents ()
- {
- register Dev_KbdEvent *events; /* Array of events */
- register int numEvents; /* Number of events left */
- int nE; /* Total number of events */
- DevicePtr pPointer; /* System pointer */
- DevicePtr pKeyboard; /* System keyboard */
- register PtrPrivPtr ptrPriv; /* Private data for pointer */
- register KbPrivPtr kbdPriv; /* Private data for keyboard */
- Dev_KbdEvent *lastEvent; /* Last event processed */
- enum {
- NoneYet, Ptr, Kbd
- } lastType = NoneYet; /* Type of last event */
-
- if (spriteCheckInput & READ_INPUT) {
- pPointer = LookupPointerDevice();
- pKeyboard = LookupKeyboardDevice();
-
- ptrPriv = (PtrPrivPtr)pPointer->devicePrivate;
- kbdPriv = (KbPrivPtr)pKeyboard->devicePrivate;
-
- /*
- * Get events from both the pointer and the keyboard via the keyboard's
- * GetEvents vector. The number of events read is stored in numEvents.
- */
- events = (* kbdPriv->GetEvents) (pKeyboard, &nE);
- numEvents = nE;
-
- while (numEvents) {
- if (events->device == DEV_KBD_KEY) {
- if (lastType == Ptr) {
- (* ptrPriv->DoneEvents) (pPointer, FALSE);
- lastType = Kbd;
- }
- (* kbdPriv->ProcessEvent) (pKeyboard, events);
- } else if (events->device == DEV_KBD_MOUSE) {
- if (lastType == Kbd) {
- (* kbdPriv->DoneEvents) (pKeyboard, FALSE);
- lastType = Ptr;
- }
- (* ptrPriv->ProcessEvent) (pPointer, events);
- } else {
- /* ??? */
- }
- lastEvent = events;
- lastEventTimeMS = events->time;
- numEvents -= 1;
- events += 1;
- }
-
- SetTimeSinceLastInputEvent();
- if (screenSaved) {
- SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
- }
-
- (* kbdPriv->DoneEvents) (pKeyboard, TRUE);
- (* ptrPriv->DoneEvents) (pPointer, TRUE);
- }
-
-
- if (spriteCheckInput & RESTORE_CURSOR) {
- spriteRestoreCursor();
- }
- spriteCheckInput = 0;
- }
- @
-
-
- 1.2
- log
- @adapted to Beta-0
- @
- text
- @d19 1
- a19 1
- "$Header: spriteIo.c,v 1.1 87/06/16 12:21:00 deboor Exp $ SPRITE (Berkeley)";
- d26 9
- a34 1
- int lastEventTime = 0;
- d51 1
- a51 1
- * spriteCheckInput is bumped
- d191 1
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d19 1
- a19 1
- "$Header: spriteIo.c,v 2.7 87/05/13 15:06:53 deboor Exp $ SPRITE (Berkeley)";
- d34 2
- a35 2
- * sunInputAvail --
- * This is a function required by the sunCursor code which is
- d48 1
- a48 1
- sunInputAvail()
- d196 1
- d198 1
- a198 1
- sunRestoreCursor();
- a200 19
- }
-
- /*-
- *-----------------------------------------------------------------------
- * sunUseSunWindows --
- * Fake function to allow use of sunCursor.c
- *
- * Results:
- * FALSE.
- *
- * Side Effects:
- * None.
- *
- *-----------------------------------------------------------------------
- */
- Boolean
- sunUseSunWindows()
- {
- return FALSE;
- @
-